What is cloudinary-core?
The cloudinary-core npm package is a JavaScript library that provides a set of tools for managing and transforming media assets using Cloudinary's cloud-based service. It allows developers to easily upload, manipulate, and deliver images and videos in their web applications.
What are cloudinary-core's main functionalities?
Image Upload
This feature allows you to upload images to Cloudinary and generate URLs for accessing them. The code sample demonstrates how to create a Cloudinary instance and generate a URL for an uploaded image.
const cloudinary = require('cloudinary-core');
const cl = new cloudinary.Cloudinary({ cloud_name: 'your_cloud_name', secure: true });
const imageUrl = cl.url('sample.jpg');
console.log(imageUrl);
Image Transformation
This feature allows you to apply various transformations to images, such as resizing, cropping, and applying effects. The code sample demonstrates how to generate a URL for an image with specific transformations applied.
const cloudinary = require('cloudinary-core');
const cl = new cloudinary.Cloudinary({ cloud_name: 'your_cloud_name', secure: true });
const transformedImageUrl = cl.url('sample.jpg', { width: 300, height: 300, crop: 'fill' });
console.log(transformedImageUrl);
Video Transformation
This feature allows you to apply transformations to videos, similar to image transformations. The code sample demonstrates how to generate a URL for a video with specific transformations applied.
const cloudinary = require('cloudinary-core');
const cl = new cloudinary.Cloudinary({ cloud_name: 'your_cloud_name', secure: true });
const transformedVideoUrl = cl.video_url('sample.mp4', { width: 300, height: 300, crop: 'fill' });
console.log(transformedVideoUrl);
Responsive Images
This feature allows you to generate URLs for responsive images that automatically adjust to different screen sizes. The code sample demonstrates how to generate a URL for a responsive image.
const cloudinary = require('cloudinary-core');
const cl = new cloudinary.Cloudinary({ cloud_name: 'your_cloud_name', secure: true });
const responsiveImageUrl = cl.url('sample.jpg', { responsive: true });
console.log(responsiveImageUrl);
Other packages similar to cloudinary-core
imgix-core-js
The imgix-core-js package provides similar functionalities for managing and transforming images using the Imgix service. It allows developers to easily generate URLs for images with various transformations applied. Compared to cloudinary-core, imgix-core-js focuses solely on image transformations and does not support video transformations.
filestack-js
The filestack-js package offers a comprehensive set of tools for file uploading, transformation, and delivery using the Filestack service. It supports both images and videos, similar to cloudinary-core. However, Filestack provides additional features such as file storage and security options.
imagekit-javascript
The imagekit-javascript package provides functionalities for image and video management, including uploading, transformation, and optimization using the ImageKit service. It offers similar features to cloudinary-core but also includes advanced optimization techniques for faster delivery.
Cloudinary Javascript Core SDK (Legacy)
About
The Javascript SDK allows you to quickly and easily integrate your application with Cloudinary.
Effortlessly optimize and transform your cloud's assets.
Note
This Readme provides basic installation and usage information.
For the complete documentation, see the Javascript SDK Guide.
Table of Contents
Key Features
Browser Support
Chrome, Safari, Firefox, IE 11
Installation
Install using your favorite package manager (yarn, npm)
npm install cloudinary-core
Or
yarn add cloudinary-core
Usage
Setup
There are several ways to configure cloudinary-core:
Explicitly
var cl = cloudinary.Cloudinary.new( { cloud_name: "demo"});
Using the config function
var cl = cloudinary.Cloudinary.new();
cl.config( "cloud_name", "demo");
From meta tags in the current HTML document
When using the library in a browser environment, you can use meta tags to define the configuration options.
The init()
function is a convenience function that invokes both fromDocument()
and fromEnvironment()
.
For example, add the following to the header tag:
<meta name="cloudinary_cloud_name" content="demo">
In your JavaScript source, invoke fromDocument()
:
var cl = cloudinary.Cloudinary.new();
cl.fromDocument();
cl.init();
From environment variables
When using the library in a backend environment such as NodeJS, you can use an environment variable to define the configuration options.
Set the environment variable, for example:
export CLOUDINARY_URL=cloudinary://demo
In your JavaScript source, invoke fromEnvironment()
:
var cl = cloudinary.Cloudinary.new();
cl.fromEnvironment();
cl.init();
Transform and Optimize Assets
cl.url( "sample", { crop: "scale", width: "200", angle: "10" })
cl.url( "sample", {
transformation: [
{ angle: -45 },
{ effect: "trim", angle: "45", crop: "scale", width: "600" },
{ overlay: "text:Arial_100:Hello" }
]
});
Generate Image and Video HTML Tags
- Use the
image()
function to generate an HTMLImageElement - Use the
imageTag()
function to generate an ImageTag instance - Use the
video()
function to generate an HTMLVideoElement - Use the
videoTag()
function to generate a VideoTag instance
File upload
See cloudinary-jquery-file-upload.
Contributions
- Ensure tests run locally (
npm run test
) - Open a PR and ensure Travis tests pass
Get Help
If you run into an issue or have a question, you can either:
About Cloudinary
Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive and personalized visual-media experiences—irrespective of the viewing device.
Additional Resources
- Cloudinary Transformation and REST API References: Comprehensive references, including syntax and examples for all SDKs.
- MediaJams.dev: Bite-size use-case tutorials written by and for Cloudinary Developers
- DevJams: Cloudinary developer podcasts on YouTube.
- Cloudinary Academy: Free self-paced courses, instructor-led virtual courses, and on-site courses.
- Code Explorers and Feature Demos: A one-stop shop for all code explorers, Postman collections, and feature demos found in the docs.
- Cloudinary Roadmap: Your chance to follow, vote, or suggest what Cloudinary should develop next.
- Cloudinary Facebook Community: Learn from and offer help to other Cloudinary developers.
- Cloudinary Account Registration: Free Cloudinary account registration.
- Cloudinary Website: Learn about Cloudinary's products, partners, customers, pricing, and more.
Licence
Released under the MIT license.